import {
  exportUrlNew,
  getFactoryCodeList,
  getSimulatedTypeList,
  getProdOrderTypeList,
  getBackflushTypeList,
  getOrderBarcodeRuleList,
  getBomVersionNumberList,
  getProdOrderStatusList
} from "@/api/order/mesProdOrder"
import {
  getLineCodeList //查询线体
} from "@/api/employee/mesUserExtend"

import excelUpload from "@/components/excel-upload/excelUpload"
import url from "@/axios/url"
const { mesUrl } = url()
let vm = null
const sendThis = (_this) => {
  vm = _this
}
export { sendThis }
// 列表头按钮配置
export const operateList = [
  {
    name: $i18n.t("common.export"),
    type: "primary",
    icon: "el-icon-download",
    handleName: "export", // 点击时返回的标识
    url: exportUrlNew
    // auth: "auth:operlog:export", //权限字段
  }
]
// 行末按钮配置
export const rowConfig = [
  // {
  //   name: "修改",
  //   type: "primary",
  //   class: "row-btn-primary",
  //   handleName: "edit", // 点击时返回的标识
  // },
  // {
  //   name: "详情",
  //   type: "info",
  //   class: "row-btn-info",
  //   handleName: "detail", // 点击时返回的标识
  // },
  // {
  //   name: "删除",
  //   type: "danger",
  //   class: "row-btn-danger",
  //   handleName: "delete", // 点击时返回的标识
  // },
]
// 搜索条件配置
export const searchConfig = {
  data() {
    const self = this
    return {
      searchDialog: {
        inline: true,
        formDesc: {
          // factoryCode: {
          //   type: "select",
          //   label: "工厂编码",
          //   type: 'select',
          //   prop: {
          //     value: "modelingCode",
          //     text: "modelingName",
          //   },
          //   options: async (data) => {
          //     const list = await getFactoryCodeList()
          //     return list.data.result
          //   },
          // },

          orderCode: {
            type: "input",
            label: $i18n.t("mesProdOrderTraceReport.productWorkOrder")
          },
          planBeginDate: {
            type: "daterange",
            label: $i18n.t("mesProdOrderTraceReport.planBeginDate"),
            attrs: {
              valueFormat: "yyyy-MM-dd",
              searchArrKey: ["planBeginDateMin", "planBeginDateMax"]
            }
          },
          prodCode: {
            type: "input",
            label: $i18n.t("mesProdOrderTraceReport.prodCode")
          },

          prodOrderType: {
            label: $i18n.t("mesProdOrderTraceReport.prodOrderType"),
            type: "select",
            prop: {
              value: "value",
              text: "description"
            },
            options: async (data) => {
              const list = await getProdOrderTypeList()
              return list.data.result
            }
          },

          lineCode: {
            label: $i18n.t("common.line"),
            type: "select",
            prop: {
              value: "modelingCode",
              text: "modelingName"
            },
            options: async (data) => {
              const params = {
                modelingCode: self.$store.getters.factoryCode,
                level: 5
              }
              const list = await getLineCodeList(params)
              return list.data.result
            }
          },
          orderStatus: {
            label: $i18n.t("mesProdOrderTraceReport.orderStatus"),
            type: "select",

            prop: {
              value: "value",
              text: "description"
            },
            options: async (data) => {
              const list = await getProdOrderStatusList()
              return list.data.result
            }
          }
        }
      }
    }
  }
}

export const configformDescDialog = {
  data() {
    return {
      // 新增/删除表单配置
      formDescDialog: {
        span: 24,
        disabled: false,
        isShowSubmitBtn: true,
        formDesc: {
          // factoryCode: {
          //   type: "select",
          //   label: "工厂编码",
          //   layout: 12,
          //   required: true,
          //   prop: {
          //     value: "modelingCode",
          //     text: "modelingName",
          //   },
          //   options: async (data) => {
          //     const list = await getFactoryCodeList()
          //     return list.data.result
          //   },
          // },
          // saleCode: {
          //   type: "select",
          //   label: "销售订单",
          //   layout: 8,
          //   required: true,
          // },
          orderCode: {
            type: "input",
            label: $i18n.t("mesProdOrderTraceReport.orderCode"),
            layout: 8,
            disabled: (d) => !!d.id,
            required: true
          },
          prodCode: {
            type: "input",
            label: $i18n.t("mesProdOrderTraceReport.prodCode"),
            layout: 8,
            required: true
          },

          prodName: {
            type: "input",
            label: $i18n.t("mesProdOrderTraceReport.prodName"),
            layout: 8,
            required: false,
            disabled: true
          },
          seriesCode: {
            type: "input",
            label: $i18n.t("mesProdOrderTraceReport.seriesCode"),
            layout: 8,
            required: true,
            disabled: true
          },

          seriesName: {
            type: "input",
            label: $i18n.t("mesProdOrderTraceReport.seriesName"),
            layout: 8,
            disabled: true
          },
          measureUnits: {
            type: "input",
            label: $i18n.t("mesProdOrderTraceReport.measureUnits"),
            layout: 8,
            disabled: true
          },
          bomVersionNumber: {
            type: "input",
            label: $i18n.t("mesProdOrderTraceReport.bomVersionNumber"),
            layout: 8,
            required: true
          },
          simulatedType: {
            type: "select",
            label: $i18n.t("mesProdOrderTraceReport.simulatedType"),
            layout: 8,
            required: true,
            prop: {
              value: "value",
              text: "description"
            },
            options: async (data) => {
              const list = await getSimulatedTypeList()
              return list.data.result
            }
          },
          prodOrderType: {
            type: "select",
            label: $i18n.t("mesProdOrderTraceReport.prodOrderType"),
            layout: 8,
            required: true,
            prop: {
              value: "value",
              text: "description"
            },
            options: async (data) => {
              const list = await getProdOrderTypeList()
              return list.data.result
            }
          },
          // priority: {
          //   type: "number",
          //   label: "订单优先级",
          //   layout: 8,
          //   required: true,
          //   min: 1,
          // },
          // technologyId: {
          //   type: "input",
          //   label: "工艺建模流程主键",
          //   layout: 12,
          //   required: true,
          // },
          deliveryDate: {
            type: "date",
            label: $i18n.t("mesProdOrderTraceReport.deliveryDate"),
            layout: 8,
            required: false,
            attrs: {
              valueFormat: "yyyy-MM-dd"
            }
          },
          slackTime: {
            type: "number",
            label: $i18n.t("mesProdOrderTraceReport.slackTime"),
            layout: 8,
            required: false
          },
          quantity: {
            type: "number",
            label: $i18n.t("mesProdOrderTraceReport.quantity"),
            layout: 8,
            required: true
          },

          planBeginDate: {
            type: "date",
            label: $i18n.t("mesProdOrderTraceReport.planBeginDate"),
            layout: 8,
            required: true,
            attrs: {
              valueFormat: "yyyy-MM-dd"
            }
          },
          planEndDate: {
            type: "date",
            label: $i18n.t("mesProdOrderTraceReport.planEndDate"),
            layout: 8,
            required: false,
            attrs: {
              valueFormat: "yyyy-MM-dd"
            }
          },
          advanceCode: {
            type: "input",
            label: $i18n.t("mesProdOrderTraceReport.advanceCode"),
            layout: 8,
            required: false
          },
          backflushType: {
            type: "select",
            label: $i18n.t("mesProdOrderTraceReport.backflushType"),
            layout: 8,
            required: false,
            prop: {
              value: "value",
              text: "description"
            },
            options: async (data) => {
              const list = await getBackflushTypeList()
              return list.data.result
            }
          },
          remark: {
            type: "textarea",
            label: $i18n.t("mesProdOrderTraceReport.remark"),
            layout: 8,
            required: false
          }
        }
      }
    }
  }
}

export const configformDescDialog_generate = {
  data() {
    const _this = this
    return {
      // 下发表单配置
      formDescDialog_generate: {
        span: 24,
        disabled: false,
        isShowSubmitBtn: true,
        ids: "",
        submitProdLineList: "",
        formDesc: {
          lineCode: {
            type: "select",
            label: $i18n.t("mesProdOrderTraceReport.lineCode"),
            layout: 24,
            required: true,
            attrs: {
              filterable: true
            },
            prop: {
              value: "modelingCode",
              text: "modelingName"
            },
            options: async (data) => {
              const params = {
                modelingCode: this.$store.getters.factoryCode,
                level: 5
              }
              const list = await getLineCodeList(params)
              this.lineList = list.data.result
              return list.data.result
            }
          },
          orderBarcodeRuleCode: {
            type: "select",
            label: $i18n.t("mesProdOrderTraceReport.orderBarcodeRuleCode"),
            layout: 24,
            required: true,
            prop: {
              value: "code",
              text: "description"
            },
            options: async (data) => {
              const list = await getOrderBarcodeRuleList()
              this.orderBarcodeRuleList = list.data.result
              return list.data.result
            }
          }
        }
      }
    }
  }
}
